package edu.uwosh.cs342.project3;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class FinalScore extends Activity {

	int score;
	int numberOfQuestions;
	String quizTitle;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.finalscore);
		
		Bundle extras = getIntent().getExtras();
		score = extras.getInt("score");
		numberOfQuestions = extras.getInt("numberOfQuestions");
		quizTitle = extras.getString("title");
		
		TextView showScoreTextView = (TextView) findViewById(R.id.scoreDisplayTextView);
		showScoreTextView.setText(score +"  /  " + numberOfQuestions);
		
		TextView showScorePercentTextView = (TextView) findViewById(R.id.percentTextView);
		showScorePercentTextView.setText(Math.round((double)score * 100 / (double)numberOfQuestions) + " %");
		
		Button finishButton = (Button) findViewById(R.id.finishButton);
		finishButton.setOnClickListener(new View.OnClickListener() {
        	public void onClick(View v){
        		finish();
        	}
        		
        });
		
		Button viewScoresButton = (Button) findViewById(R.id.viewAllScoresButton);
		viewScoresButton.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				//  go to the view scores activity
				startActivity(new Intent("android.intent.action.VIEWSCORES"));
			}
		});
		
	}
	
	@Override
	public void onBackPressed() {
	   return;
	}
	
	@Override
	public void finish() {
		startActivity(new Intent(this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
	}
	
}
